package com.teach.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.teach.exception.CodeException;
import com.teach.service.NewsClassService;

/**<pre>
 * 新闻类别控制器
 * 创建时间 ：	2019年12月2日 下午2:58:02
 * 当前版本：	V1.0
 * Copyright © 1998 - 2019 jlzhou.top. All Rights Reserved	
 * </pre>
 * @author J.L.Zhou
 *
 */
@Controller
@RequestMapping("/")
public class NewsClassController {
	
	@Autowired
	private NewsClassService service;

	@RequestMapping("news-class.do")
	public String doList(String mb,Model model){
		model.addAttribute("list", service.listAll());
		if(StringUtils.isEmpty(mb)){
			return "news-class";
		}else{
			return mb;
		}
	}
	
	@RequestMapping("news-class-json.do")
	@ResponseBody
	public Object doList(){
		return service.listAll();
	}
	
	@RequestMapping("news-class-error.do")
	@ResponseBody
	public Object doError(){
		throw new CodeException(0);
	}
}
